package com.niknik.woody.rest.jersey;

import com.niknik.woody.rest.response.*;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.api.json.JSONJAXBContext;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import javax.xml.bind.JAXBContext;

@Provider
public final class RestRespFormatter
    implements ContextResolver<JAXBContext> {

  private final JAXBContext _context;

  public RestRespFormatter()
      throws Exception {
    this._context = new JSONJAXBContext(JSONConfiguration.natural().build(), RoomsResponse.class,
        CreateRoomResponse.class, RoomTokenResponse.class, WResponse.class, RoomDto.class);
  }

  public JAXBContext getContext(Class<?> objectType) {
    return _context;
  }
} 